package org.cobaya.commons;

import java.io.File;
import java.io.IOException;
import java.util.Properties;

public abstract class Props {

	public static Properties openProperties(File file) throws IOException {
		IO.assertFileReadable(file);
		IO.assertFileExtension(file, "properties");
		Properties props = new Properties();
		props.load(IO.openInputStream(file));
		return props;
	}

	public static Properties openProperties(String path) throws IOException {
		return openProperties(IO.openFile(path));
	}

	public static String getProperties(File file, String key) throws IOException {
		return openProperties(file).getProperty(key);
	}

	public static String getProperties(String path, String key) throws IOException {
		return openProperties(path).getProperty(key);
	}
}